<?php
namespace app\index\model;

use think\Model;
use think\cache\driver\Redis;

class RedisModel extends Model
{
    private $redis;
    public function  __construct()
    {
        parent::__construct();
        $this->redis = new Redis();
    }

    /**
     *  存储redis
     *  @param string $key
     *  @param string $val
     *  @param string $time 过期时间
     *  @return bool
     **/
    public function redisSet($key, $val, $time = 300)
    {
        return $this->redis->set($key, $val, $time);
    }

    /**
     *  获取redis
     *  @param string $key
     *  @return string
     **/
    public function redisGet($key)
    {
        return $this->redis->get($key);
    }

    /**
     *  删除redis
     *  @param string $key
     *  @return string
     **/
    public function redisDel($key)
    {
        return $this->redis->rm($key);
    }
}
